using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;using Maxleaf.EDI.Domain.K3;

namespace Maxleaf.EDI.DataAccess.K3
{
    public class t_StockPlaceMap : EntityTypeConfiguration<t_StockPlace>
    {
        public t_StockPlaceMap()
        {
            // Primary Key
            this.HasKey(t => t.FSPID);

            // Properties
            this.Property(t => t.FSPID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.FNumber)
                .IsRequired()
                .HasMaxLength(80);

            this.Property(t => t.FName)
                .IsRequired()
                .HasMaxLength(80);

            this.Property(t => t.FFullName)
                .HasMaxLength(255);

            this.Property(t => t.FFullNumber)
                .IsRequired()
                .HasMaxLength(80);

            this.Property(t => t.FShortNumber)
                .HasMaxLength(80);

            this.Property(t => t.FDescription)
                .HasMaxLength(255);

            this.Property(t => t.FModifyTime)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(8)
                .IsRowVersion();

            // Table & Column Mappings
            this.ToTable("t_StockPlace");
            this.Property(t => t.FSPID).HasColumnName("FSPID");
            this.Property(t => t.FSPGroupID).HasColumnName("FSPGroupID");
            this.Property(t => t.FNumber).HasColumnName("FNumber");
            this.Property(t => t.FName).HasColumnName("FName");
            this.Property(t => t.FFullName).HasColumnName("FFullName");
            this.Property(t => t.FLevel).HasColumnName("FLevel");
            this.Property(t => t.FDetail).HasColumnName("FDetail");
            this.Property(t => t.FParentID).HasColumnName("FParentID");
            this.Property(t => t.FFullNumber).HasColumnName("FFullNumber");
            this.Property(t => t.FShortNumber).HasColumnName("FShortNumber");
            this.Property(t => t.FDescription).HasColumnName("FDescription");
            this.Property(t => t.FDeleted).HasColumnName("FDeleted");
            this.Property(t => t.FModifyTime).HasColumnName("FModifyTime");
            this.Property(t => t.FSystemType).HasColumnName("FSystemType");
            this.Property(t => t.UUID).HasColumnName("UUID");
            this.Property(t => t.FClassTypeID).HasColumnName("FClassTypeID");

            // Relationships
            this.HasRequired(t => t.t_StockPlaceGroup)
                .WithMany(t => t.t_StockPlace)
                .HasForeignKey(d => d.FSPGroupID);

        }
    }
}
